/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.hpvas.gui.internalframe;

import edu.hpvas.control.OwnerController;
import edu.hpvas.control.Restrictions;
import edu.hpvas.control.VeterinarianController;
import edu.hpvas.persistence.entity.Veterinarian;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Date;
import javax.swing.JOptionPane;

/**
 *
 * @author sony
 */
public class VeterinarianUpdateIF extends javax.swing.JInternalFrame {

    public Veterinarian veterinarian = new Veterinarian();
    public Restrictions restric = new Restrictions();
    public ArrayList<Veterinarian> veterinarians = new ArrayList<>();
    public VeterinarianController vetC= new VeterinarianController();
    Restrictions restrictions = new Restrictions();
    /**
     * Creates new form updateInternalFrame
     */
    public VeterinarianUpdateIF() {
        initComponents();
        int ancho=900;
        int alto=500;
        setSize(ancho, alto);
        initForms();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        nameJL = new javax.swing.JLabel();
        nameJT = new javax.swing.JTextField();
        lastNameJL = new javax.swing.JLabel();
        lastNameJT = new javax.swing.JTextField();
        birthPlaceJL = new javax.swing.JLabel();
        birthPlaceJT = new javax.swing.JTextField();
        birthDayJL = new javax.swing.JLabel();
        errorMJL = new javax.swing.JLabel();
        yearJL = new javax.swing.JLabel();
        yearJCB = new javax.swing.JComboBox();
        monthJL = new javax.swing.JLabel();
        monthJCB = new javax.swing.JComboBox();
        dayJL = new javax.swing.JLabel();
        dayJCB = new javax.swing.JComboBox();
        ssnJL = new javax.swing.JLabel();
        SSNJT = new javax.swing.JTextField();
        updateJB = new javax.swing.JButton();
        cancelJB1 = new javax.swing.JButton();
        nameSearchJTF = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        errorSearchJL = new javax.swing.JLabel();
        nameSJCB = new javax.swing.JComboBox();
        searchJB = new javax.swing.JButton();
        backJB = new javax.swing.JButton();
        caractersJL = new javax.swing.JLabel();
        focusJL = new javax.swing.JLabel();
        specialJL = new javax.swing.JLabel();
        salaryJL = new javax.swing.JLabel();
        graduateJL = new javax.swing.JLabel();
        graduatedAtJT = new javax.swing.JTextField();
        salaryJT = new javax.swing.JTextField();
        specialitiesJT = new javax.swing.JTextField();
        focusOfPracticeJT = new javax.swing.JTextField();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Update Veterinarian", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, new java.awt.Color(0, 0, 102)));

        nameJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        nameJL.setText("Name:");

        nameJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nameJTMouseClicked(evt);
            }
        });
        nameJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                nameJTKeyPressed(evt);
            }
        });

        lastNameJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        lastNameJL.setText("Lastname: ");

        lastNameJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lastNameJTMouseClicked(evt);
            }
        });
        lastNameJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                lastNameJTKeyPressed(evt);
            }
        });

        birthPlaceJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        birthPlaceJL.setText("BirthPlace");

        birthPlaceJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                birthPlaceJTMouseClicked(evt);
            }
        });
        birthPlaceJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                birthPlaceJTKeyPressed(evt);
            }
        });

        birthDayJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        birthDayJL.setText("Birth Day:");

        errorMJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        errorMJL.setForeground(new java.awt.Color(204, 0, 0));
        errorMJL.setText("The date is Uncompleted");

        yearJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        yearJL.setText("Year");

        yearJCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "----", "2012", "2011", "2010", "2009", "2008", "2007", "2006", "2005", "2004", "2003", "2002", "2001", "2000", "1999", "1998", "1997", "1996", "1995", "1994", "1993", "1992", "1991", "1990", "1989", "1988", "1987", "1986", "1985", "1984", "1983", "1982", "1981", "1980", "1979", "1978", "1977", "1976", "1975", "1974", "1973", "1972", "1971", "1970", "1969", "1968", "1967", "1966", "1965", "1964", "1963", "1962", "1961", "1960", "1959", "1958", "1957", "1956", "1955", "1954", "1953", "1952", "1951", "1950", "1949", "1948", "1947", "1946", "1945", "1944", "1943", "1942", "1941", "1940", "1939", "1938", "1937", "1936", "1935", "1934", "1933", "1932", "1931", "1930", "1929", "1928", "1927", "1926", "1925", "1924", "1923", "1922", "1921", "1920" }));
        yearJCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yearJCBActionPerformed(evt);
            }
        });

        monthJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        monthJL.setText("Month");

        monthJCB.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-------", "January", "Febrary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", " " }));
        monthJCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                monthJCBActionPerformed(evt);
            }
        });

        dayJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        dayJL.setText("Day");

        dayJCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dayJCBActionPerformed(evt);
            }
        });

        ssnJL.setText("SSN:");

        SSNJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                SSNJTMouseClicked(evt);
            }
        });
        SSNJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                SSNJTKeyPressed(evt);
            }
        });

        updateJB.setText("Update");
        updateJB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                updateJBActionPerformed(evt);
            }
        });

        cancelJB1.setText("Cancel");
        cancelJB1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelJB1ActionPerformed(evt);
            }
        });

        nameSearchJTF.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nameSearchJTFMouseClicked(evt);
            }
        });

        jLabel9.setText("Search by name & Last Name");

        jButton3.setText("Enter");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        errorSearchJL.setForeground(new java.awt.Color(204, 0, 0));
        errorSearchJL.setText("The special caracters are not allowed... try again");

        nameSJCB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nameSJCBActionPerformed(evt);
            }
        });

        searchJB.setText("Select");
        searchJB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchJBActionPerformed(evt);
            }
        });

        backJB.setText("Back");
        backJB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backJBActionPerformed(evt);
            }
        });

        caractersJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        caractersJL.setForeground(new java.awt.Color(255, 0, 0));
        caractersJL.setText("The special caracters are not allowed... try again");

        focusJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        focusJL.setText("Focus Of Practice");

        specialJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        specialJL.setText("Specialities");

        salaryJL.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        salaryJL.setText("Salary");

        graduateJL.setText("Graduated At");

        graduatedAtJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                graduatedAtJTMouseClicked(evt);
            }
        });
        graduatedAtJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                graduatedAtJTKeyPressed(evt);
            }
        });

        salaryJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                salaryJTMouseClicked(evt);
            }
        });
        salaryJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                salaryJTKeyPressed(evt);
            }
        });

        specialitiesJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                specialitiesJTMouseClicked(evt);
            }
        });
        specialitiesJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                specialitiesJTKeyPressed(evt);
            }
        });

        focusOfPracticeJT.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                focusOfPracticeJTMouseClicked(evt);
            }
        });
        focusOfPracticeJT.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                focusOfPracticeJTKeyPressed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGap(99, 99, 99)
                            .addComponent(jLabel9)
                            .addGap(18, 18, 18)
                            .addComponent(nameSearchJTF, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton3))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(172, 172, 172)
                                    .addComponent(errorSearchJL, javax.swing.GroupLayout.PREFERRED_SIZE, 265, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGap(260, 260, 260)
                                    .addComponent(nameSJCB, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(50, 50, 50)
                                    .addComponent(searchJB, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGap(0, 0, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(lastNameJL)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(lastNameJT, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                            .addGap(34, 34, 34)
                            .addComponent(nameJL)
                            .addGap(4, 4, 4)
                            .addComponent(nameJT, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(134, 134, 134))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(backJB, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(119, 119, 119))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(yearJL)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(yearJCB, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(birthDayJL))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(monthJL)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(monthJCB, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(dayJL)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(dayJCB, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE))
                                    .addComponent(errorMJL, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(29, 29, 29)
                                .addComponent(ssnJL)
                                .addGap(18, 18, 18)
                                .addComponent(SSNJT, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(birthPlaceJL)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(birthPlaceJT, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(salaryJL)
                                    .addGap(18, 18, 18)
                                    .addComponent(salaryJT, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(specialJL)
                                        .addGap(18, 18, 18)
                                        .addComponent(specialitiesJT, javax.swing.GroupLayout.PREFERRED_SIZE, 239, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addGap(10, 10, 10)
                                        .addComponent(focusJL)
                                        .addGap(18, 18, 18)
                                        .addComponent(focusOfPracticeJT, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(26, 26, 26)
                                .addComponent(graduateJL)
                                .addGap(32, 32, 32)
                                .addComponent(graduatedAtJT, javax.swing.GroupLayout.PREFERRED_SIZE, 254, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGap(78, 78, 78))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(caractersJL, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(updateJB, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(cancelJB1, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(64, 64, 64))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(nameSearchJTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton3))
                .addGap(8, 8, 8)
                .addComponent(errorSearchJL)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nameSJCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchJB))
                .addGap(18, 18, 18)
                .addComponent(backJB)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(nameJL)
                            .addComponent(nameJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lastNameJL)
                            .addComponent(lastNameJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(birthPlaceJL)
                            .addComponent(birthPlaceJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(birthDayJL)
                            .addComponent(errorMJL)
                            .addComponent(graduateJL))
                        .addGap(15, 15, 15)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(monthJL)
                            .addComponent(yearJL)
                            .addComponent(monthJCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(yearJCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dayJL)
                            .addComponent(dayJCB, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(ssnJL)
                            .addComponent(SSNJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(caractersJL))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(focusJL)
                            .addComponent(focusOfPracticeJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(specialJL)
                            .addComponent(specialitiesJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(20, 20, 20)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(salaryJL)
                            .addComponent(salaryJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(graduatedAtJT, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cancelJB1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(updateJB, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(10, 10, 10))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nameJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nameJTMouseClicked
        if(nameJT.getText().equals("The name cannot be blank")){
            nameJT.setText("");
            nameJT.setForeground(Color.black);
        }
    }//GEN-LAST:event_nameJTMouseClicked

    private void nameJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nameJTKeyPressed

    }//GEN-LAST:event_nameJTKeyPressed

    private void lastNameJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lastNameJTMouseClicked
        if(lastNameJT.getText().equals("The lastname cannot be blank")){
            lastNameJT.setText("");
            lastNameJT.setForeground(Color.black);
        }
    }//GEN-LAST:event_lastNameJTMouseClicked

    private void lastNameJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lastNameJTKeyPressed

    }//GEN-LAST:event_lastNameJTKeyPressed

    private void birthPlaceJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_birthPlaceJTMouseClicked
        if(birthPlaceJT.getText().equals("The Birt Place cannot be blank")){
            birthPlaceJT.setText("");
            birthPlaceJT.setForeground(Color.black);
        }
    }//GEN-LAST:event_birthPlaceJTMouseClicked

    private void birthPlaceJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_birthPlaceJTKeyPressed

    }//GEN-LAST:event_birthPlaceJTKeyPressed

    private void yearJCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearJCBActionPerformed
        errorMJL.setVisible(false);
        dayJCB.setVisible(false);
        dayJL.setVisible(false);
        if(yearJCB.getSelectedIndex()!=0){
            if(monthJCB.getSelectedIndex()!=0){
                dayJCB.setVisible(true);
                dayJL.setVisible(true);
            }
        }
        monthSelected();
    }//GEN-LAST:event_yearJCBActionPerformed

    private void monthJCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monthJCBActionPerformed
        errorMJL.setVisible(false);
        dayJCB.setVisible(false);
        dayJL.setVisible(false);
        monthSelected();
        if(monthJCB.getSelectedIndex()!=0){
            if(yearJCB.getSelectedIndex()!=0){
                dayJCB.setVisible(true);
                dayJL.setVisible(true);
            }
        }
    }//GEN-LAST:event_monthJCBActionPerformed

    private void dayJCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dayJCBActionPerformed
        errorMJL.setVisible(false);
    }//GEN-LAST:event_dayJCBActionPerformed

    private void SSNJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SSNJTMouseClicked
        if(SSNJT.getText().equals("The SSN cannot be blank")){
            SSNJT.setText("");
            SSNJT.setForeground(Color.black);
        }
    }//GEN-LAST:event_SSNJTMouseClicked

    private void SSNJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_SSNJTKeyPressed

    }//GEN-LAST:event_SSNJTKeyPressed

    private void updateJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateJBActionPerformed

        caractersJL.setVisible(false);
        if(nameJT.getText().isEmpty() || lastNameJT.getText().isEmpty() ||
            birthPlaceJT.getText().isEmpty() || SSNJT.getText().isEmpty()
            || yearJCB.getSelectedIndex()==0 || monthJCB.getSelectedIndex()==0
            || dayJCB.getSelectedIndex()==0){
            if(nameJT.getText().isEmpty()){
                nameJT.setText("The name cannot be blank");
                nameJT.setForeground(Color.red);
            }
            if(lastNameJT.getText().isEmpty()){
                lastNameJT.setText("The lastname cannot be blank");
                lastNameJT.setForeground(Color.red);
            }
            if(birthPlaceJT.getText().isEmpty()){
                birthPlaceJT.setText("The Birt Place cannot be blank");
                birthPlaceJT.setForeground(Color.red);
            }
            if(SSNJT.getText().isEmpty()){
                SSNJT.setText("The SSN cannot be blank");
                SSNJT.setForeground(Color.red);
            }
            if(yearJCB.getSelectedIndex()==0 || monthJCB.getSelectedIndex()==0
                || dayJCB.getSelectedIndex()==0){
                errorMJL.setVisible(true);
            }
        }
        else{
            if(nameJT.getText().equals("The name cannot be blank") ||
                lastNameJT.getText().equals("The lastname cannot be blank") ||
                birthPlaceJT.getText().equals("The Birt Place cannot be blank")||
                SSNJT.getText().equals("The SSN cannot be blank")){
                JOptionPane.showMessageDialog(this, "error, try Again");
            }
            else if(!restrictions.validateSpecialC(nameJT.getText())){

                caractersJL.setVisible(true);
            }
            else if(!restrictions.validateSpecialC(lastNameJT.getText())){
                caractersJL.setVisible(true);
            }
            else if(!restrictions.validateSpecialC(SSNJT.getText()))
            {
                caractersJL.setVisible(true);
            }
            else if(!restrictions.validateSpecialC(birthPlaceJT.getText())){
                caractersJL.setVisible(true);
            }
            else{

                Veterinarian vet = new Veterinarian();
                vet.setIdPerson(veterinarian.getIdPerson());
                vet.getIdPerson().setBirthPlace(birthPlaceJT.getText());
                vet.getIdPerson().setLastName(lastNameJT.getText());
                vet.getIdPerson().setName(nameJT.getText());
                vet.getIdPerson().setSsn(SSNJT.getText());
                vet.setFocusOfPractice(focusOfPracticeJT.getText());
                vet.setGraduateAt(graduatedAtJT.getText());
                vet.setSalary(new Integer(salaryJT.getText()));
                vet.setSpecialities(specialitiesJT.getText());
                Integer year = new Integer((String)yearJCB.getSelectedItem()) -1900;
                vet.getIdPerson().setBirthdate(new Date(year.intValue(), monthJCB.getSelectedIndex()-1,
                    dayJCB.getSelectedIndex()));
            boolean result = vetC.updateVeterinarian(veterinarian, veterinarian.getIdPerson().getId(),vet);
            if(result){
                JOptionPane.showMessageDialog(this, "The Veterinarian was Updated successfully");
                initForms();
                clean();
            }
            else{
                JOptionPane.showMessageDialog(this, "Error... try again");
            }
            errorMJL.setVisible(false);
        }
        }

    }//GEN-LAST:event_updateJBActionPerformed

    private void cancelJB1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelJB1ActionPerformed
        this.setVisible(false);
        nameSearchJTF.setText("");
    }//GEN-LAST:event_cancelJB1ActionPerformed

    private void nameSearchJTFMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nameSearchJTFMouseClicked

        if(nameSearchJTF.getText().equals("The field Cannot be Blank")){
            nameSearchJTF.setText("");
            nameSearchJTF.setForeground(Color.black);
        }
    }//GEN-LAST:event_nameSearchJTFMouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        errorSearchJL.setVisible(false);
        nameSJCB.removeAllItems();
        if(nameSearchJTF.getText().equals("") || nameSearchJTF.getText().equals("The field Cannot be Blank")){
            nameSearchJTF.setText("The field Cannot be Blank");
            nameSearchJTF.setForeground(Color.red);
        }
        else if(!restric.validateSpecialC(nameSearchJTF.getText())){
            errorSearchJL.setVisible(true);
        }
        else{
            veterinarians = vetC.searchVeterinarian(nameSearchJTF.getText());
            if(!veterinarians.isEmpty()){
                nameSJCB.addItem("-----------");
                nameSJCB.setVisible(true);
                searchJB.setVisible(true);
                for(Veterinarian v:veterinarians){
                    nameSJCB.addItem(v.getIdPerson().getName() + " " + v.getIdPerson().getLastName());
                }

            }
            else{
                nameSJCB.setVisible(false);
                searchJB.setVisible(false);
            }
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void nameSJCBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nameSJCBActionPerformed

    }//GEN-LAST:event_nameSJCBActionPerformed

    private void searchJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchJBActionPerformed
        if(nameSJCB.getSelectedIndex()!=0){
            veterinarian = veterinarians.get(nameSJCB.getSelectedIndex()-1);
            nameSearchJTF.setText("");
            nameSJCB.removeAll();
            nameSJCB.setVisible(false);
            searchJB.setVisible(false);
            initOwnerDates();
            showDates();
        }
    }//GEN-LAST:event_searchJBActionPerformed

    private void backJBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backJBActionPerformed
        this.setVisible(false);
        nameSearchJTF.setText("");
    }//GEN-LAST:event_backJBActionPerformed

    private void graduatedAtJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_graduatedAtJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_graduatedAtJTMouseClicked

    private void graduatedAtJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_graduatedAtJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_graduatedAtJTKeyPressed

    private void salaryJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_salaryJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_salaryJTMouseClicked

    private void salaryJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_salaryJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_salaryJTKeyPressed

    private void specialitiesJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_specialitiesJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_specialitiesJTMouseClicked

    private void specialitiesJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_specialitiesJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_specialitiesJTKeyPressed

    private void focusOfPracticeJTMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_focusOfPracticeJTMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_focusOfPracticeJTMouseClicked

    private void focusOfPracticeJTKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_focusOfPracticeJTKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_focusOfPracticeJTKeyPressed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField SSNJT;
    private javax.swing.JButton backJB;
    private javax.swing.JLabel birthDayJL;
    private javax.swing.JLabel birthPlaceJL;
    private javax.swing.JTextField birthPlaceJT;
    private javax.swing.JButton cancelJB1;
    private javax.swing.JLabel caractersJL;
    private javax.swing.JComboBox dayJCB;
    private javax.swing.JLabel dayJL;
    private javax.swing.JLabel errorMJL;
    private javax.swing.JLabel errorSearchJL;
    private javax.swing.JLabel focusJL;
    private javax.swing.JTextField focusOfPracticeJT;
    private javax.swing.JLabel graduateJL;
    private javax.swing.JTextField graduatedAtJT;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JLabel lastNameJL;
    private javax.swing.JTextField lastNameJT;
    private javax.swing.JComboBox monthJCB;
    private javax.swing.JLabel monthJL;
    private javax.swing.JLabel nameJL;
    private javax.swing.JTextField nameJT;
    private javax.swing.JComboBox nameSJCB;
    private javax.swing.JTextField nameSearchJTF;
    private javax.swing.JLabel salaryJL;
    private javax.swing.JTextField salaryJT;
    private javax.swing.JButton searchJB;
    private javax.swing.JLabel specialJL;
    private javax.swing.JTextField specialitiesJT;
    private javax.swing.JLabel ssnJL;
    private javax.swing.JButton updateJB;
    private javax.swing.JComboBox yearJCB;
    private javax.swing.JLabel yearJL;
    // End of variables declaration//GEN-END:variables
 private void monthSelected(){
        int mes = monthJCB.getSelectedIndex();
        dayJCB.removeAllItems();
        dayJCB.addItem("--");
        if(mes ==1 || mes == 3 || mes == 5 || mes == 7 || mes ==8 || mes ==10 || mes == 12)
        {   
            for(int i=1; i<=31;i++)
            {
                dayJCB.addItem(i);
            }
        }
        else if(mes ==4 || mes ==6 || mes ==9 || mes ==11)
        {
            for(int i=1;i<=30;i++)
            {
                dayJCB.addItem(i);
            }
        }
        else if(mes ==2)
        {
            for(int i=1;i<=28;i++)
            {
                dayJCB.addItem(i);
            }
            if((2013-yearJCB.getSelectedIndex())%4 ==0)
            {
                dayJCB.addItem(29);
            }

        }
    }

    private void showDates() {
        nameJT.setVisible(true);
        nameJL.setVisible(true);
         focusJL.setVisible(true);
        focusOfPracticeJT.setVisible(true);
        specialJL.setVisible(true);
        specialitiesJT.setVisible(true);
        salaryJL.setVisible(true);
        salaryJT.setVisible(true);
        graduatedAtJT.setVisible(true);
        graduateJL.setVisible(true);
        lastNameJL.setVisible(true);
        lastNameJT.setVisible(true);
        birthDayJL.setVisible(true);
        birthPlaceJL.setVisible(true);
        birthPlaceJT.setVisible(true);
        yearJCB.setVisible(true);
        dayJCB.setVisible(true);
        monthJCB.setVisible(true);
        dayJL.setVisible(true);
        monthJL.setVisible(true);
        yearJL.setVisible(true);
        SSNJT.setVisible(true);
        ssnJL.setVisible(true);
        updateJB.setVisible(true);
        nameSJCB.setVisible(true);
        searchJB.setVisible(false);
    }
    public void initForms(){
        errorSearchJL.setVisible(false);
        nameJT.setVisible(false);
        nameJL.setVisible(false);
        lastNameJL.setVisible(false);
        lastNameJT.setVisible(false);
        birthDayJL.setVisible(false);
        birthPlaceJL.setVisible(false);
        birthPlaceJT.setVisible(false);
        yearJCB.setVisible(false);
        dayJCB.setVisible(false);
        monthJCB.setVisible(false);
        dayJL.setVisible(false);
        monthJL.setVisible(false);
        yearJL.setVisible(false);
        SSNJT.setVisible(false);
        ssnJL.setVisible(false);
        updateJB.setVisible(false);
        errorMJL.setVisible(false);
        nameSJCB.setVisible(false);
        searchJB.setVisible(false);
        caractersJL.setVisible(false);
        cancelJB1.setVisible(false);
        focusJL.setVisible(false);
        focusOfPracticeJT.setVisible(false);
        specialJL.setVisible(false);
        specialitiesJT.setVisible(false);
        salaryJL.setVisible(false);
        salaryJT.setVisible(false);
        graduatedAtJT.setVisible(false);
        graduateJL.setVisible(false);
        
    }
    
    public void initOwnerDates(){
        nameJT.setText(veterinarian.getIdPerson().getName());
        lastNameJT.setText(veterinarian.getIdPerson().getLastName());
        birthPlaceJT.setText(veterinarian.getIdPerson().getBirthPlace());
        int year = 2013-(veterinarian.getIdPerson().getBirthdate().getYear()+1900);
        
        yearJCB.setSelectedIndex(year);
        monthJCB.setSelectedIndex(veterinarian.getIdPerson().getBirthdate().getMonth()+1);
        dayJCB.setSelectedIndex(veterinarian.getIdPerson().getBirthdate().getDate());
        SSNJT.setText(veterinarian.getIdPerson().getSsn());
        cancelJB1.setVisible(true);
        backJB.setVisible(false);
        focusOfPracticeJT.setText(veterinarian.getFocusOfPractice());
        specialitiesJT.setText(veterinarian.getSpecialities());
        salaryJT.setText(veterinarian.getSalary().toString());
        graduatedAtJT.setText(veterinarian.getGraduateAt());
        
        
    }
        private void clean() {
        nameJT.setText("");
        lastNameJT.setText("");
        birthPlaceJT.setText("");
        yearJCB.setSelectedIndex(0);
        monthJCB.setSelectedIndex(0);
        dayJCB.setVisible(false);
        dayJL.setVisible(false);
        SSNJT.setText("");
        backJB.setVisible(true);
    }

}
